home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / util / libs / DigNet.lha / dignet / resourcetracking / demos / sources / DignetNoFree.asm < prev   
Encoding:
Assembly Source File  |  1997-03-12  |  3.9 KB  |  141 lines

  1. *>b:DignetNoFree
  2.  
  3.     *«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  4.     *   Copyright © 1997 by Kenneth C. Nilsen.  E-Mail: kennecni@IDGonline.no              *
  5.     *   Source viewed in 800x600 with Thin711.font (11) in CED                      *
  6.     *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  7.     *
  8.     *   Name
  9.     *    DignetNoFree 1.0
  10.     *
  11.     *   Synopsis
  12.     *       Demo program for dignet.library to show the resource tracking capability.
  13.     *
  14.     *   Inputs
  15.     *    DignetNoFree <device> [unit]   unit defaults to 0 if not provided
  16.     *
  17.     *   Notes
  18.     *
  19.     *   Bugs
  20.     *    
  21.     *   Created    : 12.03.97
  22.     *   Changes    : 12.03.97
  23.     *««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  24.  
  25.  
  26. StartSkip    =    0
  27.  
  28. ;DODUMP        SET    1
  29.  
  30.  
  31.         Incdir    ""
  32.  
  33.         include    lvo:exec_lib.i
  34.         include    lvo:dos_lib.i
  35.         include    lvo:dignet_lib.i
  36.  
  37.         Incdir    inc:
  38.  
  39. ;these two files are included:
  40.  
  41.         include    digital.macs
  42.         include    startup.asm
  43.  
  44.         Incdir    ""
  45.  
  46.         dc.b    "$VER: DignetNoFree 1.0 (12.3.97)",10
  47.         dc.b    "Copyright © 1997 Digital Surface. PUBLIC DOMAIN",0
  48.         even
  49. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  50. Init        TaskName    "DignetNoFree resource tracking demo"
  51.         DefLib    dignet,2        ;version 2 of dignet.library
  52.         DefLib    dos,37            ;version 37 of dos.library
  53.         DefEnd
  54.  
  55. Start    NextArg            ;any args for this program ?
  56.     beq    About        ;none, show About/usage
  57.     move.l    d0,a0
  58.     cmp.b    #'?',(a0)    ;info wanted ? show About/Usage
  59.     beq    About
  60.  
  61.     lea    DevN(pc),a1    ;we asume a device name
  62.  
  63. .copyDevice
  64.     move.b    (a0)+,(a1)+    ;copy name to our own buffer
  65.     bne.b    .copyDevice    ;you could easily default this to serial.device
  66.  
  67.     NextArg            ;unit provided ?
  68.     beq    .noUnit        ;if no unit provided, default to 0
  69.  
  70.     move.l    d0,a0        ;this is just a demo so we take a simple convert
  71.     move.b    (a0),d0
  72.     ext.w    d0
  73.     ext.l    d0
  74.     sub.w    #48,d0        ;simple convert
  75.     move.l    d0,Unit
  76.  
  77. .noUnit
  78.     LibBase    dignet
  79.  
  80.     lea    DevN(pc),a0    ;device we want to use
  81.     move.l    Unit(pc),d0    ;unit
  82.     Call    AllocNet    ;alloc a net structure
  83.     move.l    d0,Net        ;ok, it's ready for use
  84.     beq    ErrorNet
  85.  
  86. *------------------------------------------------------------------------------------------------------------*
  87. Close    Return    0        ;quit program with 0 in return code
  88. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  89. ErrorNet
  90.     LibBase    exec            ;report error on device/unit
  91.     lea    NoNetTxt(pc),a0
  92.     lea    Table(pc),a1
  93.     move.l    #DevN,(a1)
  94.     move.l    Unit(pc),4(a1)
  95.     lea    Proc(pc),a2
  96.     lea    Buffer(pc),a3
  97.     Call    RawDoFmt
  98.  
  99.     lea    Buffer(pc),a0
  100.     bsr    Print
  101.     bra    Close
  102.  
  103. About    lea    AboutTxt(pc),a0        ;About/Usage message
  104.     bsr    Print
  105.     bra    Close
  106.  
  107. Print    movem.l    d0-a6,-(sp)        ;our sub routine that prints to def. out
  108.  
  109.     LibBase    dos
  110.     move.l    a0,d2        ;backup string ptr.
  111.     Call    Output        ;get def. outhandler
  112.     move.l    d0,d1
  113.     beq    .exit        ;null ? then exit
  114.  
  115.     move.l    d2,a0        ;start count of length of string
  116.     moveq.l    #0,d3        ;length
  117. .count    tst.b    (a0)+        ;a null termination ?
  118.     beq.b    .print        ;yep, print
  119.     addq.l    #1,d3        ;no, add one more char
  120.     bra.b    .count        ;loop
  121. .print    Call    Write        ;write string to def Out which is our console
  122.  
  123. .exit    movem.l    (sp)+,d0-a6
  124.     rts
  125.  
  126. Proc    move.b    d0,(a3)+
  127.     rts
  128. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  129. Net        dc.l    0    ;ptr. to net structure
  130. Table        dc.l    0,0    ;ptr. table for RawDoFmt()
  131.  
  132. Unit        dc.l    0    ;unit number
  133. DevN        dcb.b    80,0    ;device name, insert "serial.device" in beginning to def. to that
  134.  
  135. Buffer        dcb.b    200,0    ;buffer for chars and RawDoFmt()
  136. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  137. NoNetTxt    dc.b    "Couldn't open %s unit %ld!",10,10,0
  138. AboutTxt    dc.b    "DignetNoFree 1.0 resource tracking demo program for dignet.library",10,10
  139.         dc.b    "USAGE: DignetNoFree <device> <unit>",10,10,0
  140. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  141.